package com.hotel.controller;

import com.hotel.pojo.Orders;
import com.hotel.service.OrdersService;
import com.hotel.vo.PageResult;
import com.hotel.vo.SysResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("/orders")
public class OrdersController {
    @Autowired
    private OrdersService ordersService;

    /**
     * 展示列表并分页查询
     * @param pageResult
     * @return
     */
    @GetMapping("/ordersList")
    public SysResult ordersList(PageResult pageResult){
        pageResult = ordersService.OrdersList(pageResult);
        return SysResult.success(pageResult);
    }

    /**
     * 根据ID删除
     * @param ordersId
     * @return
     */
    @DeleteMapping("/{ordersId}")
    public SysResult deleteOrders(@PathVariable Integer ordersId){
        ordersService.deleteOrders(ordersId);
        return SysResult.success();
    }

    /**
     * 增加订单
     * @param
     * @return
     */
    @PostMapping("/addOrders/{id}")
    public SysResult addOrders(@PathVariable Integer id){
        ordersService.addOrders(id);
        return SysResult.success();
    }
}
